package org.altervista.cp.thinbcgen.bean.test;

import org.apache.bcel.generic.*;
import org.apache.bcel.classfile.*;
import org.apache.bcel.*;
import java.io.*;

public class JavaBeanInterfCreator implements Constants {
  private InstructionFactory _factory;
  private ConstantPoolGen    _cp;
  private ClassGen           _cg;

  public JavaBeanInterfCreator() {
    _cg = new ClassGen("org.altervista.cp.thinbcgen.bean.test.JavaBeanInterf", "java.lang.Object", "JavaBeanInterf.java", ACC_PUBLIC | ACC_INTERFACE | ACC_ABSTRACT, new String[] { "java.io.Serializable", "java.lang.Cloneable" });

    _cp = _cg.getConstantPool();
    _factory = new InstructionFactory(_cg, _cp);
  }

  public void create(OutputStream out) throws IOException {
    createMethod_0();
    createMethod_1();
    createMethod_2();
    createMethod_3();
    _cg.getJavaClass().dump(out);
  }

  private void createMethod_0() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC | ACC_ABSTRACT, Type.STRING, Type.NO_ARGS, new String[] {  }, "getName", "org.altervista.cp.thinbcgen.bean.test.JavaBeanInterf", il, _cp);

    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_1() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC | ACC_ABSTRACT, Type.VOID, new Type[] { Type.STRING }, new String[] { "arg0" }, "setName", "org.altervista.cp.thinbcgen.bean.test.JavaBeanInterf", il, _cp);

    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_2() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC | ACC_ABSTRACT, Type.DOUBLE, Type.NO_ARGS, new String[] {  }, "getPrice", "org.altervista.cp.thinbcgen.bean.test.JavaBeanInterf", il, _cp);

    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  private void createMethod_3() {
    InstructionList il = new InstructionList();
    MethodGen method = new MethodGen(ACC_PUBLIC | ACC_ABSTRACT, Type.VOID, new Type[] { Type.DOUBLE }, new String[] { "arg0" }, "setPrice", "org.altervista.cp.thinbcgen.bean.test.JavaBeanInterf", il, _cp);

    method.setMaxStack();
    method.setMaxLocals();
    _cg.addMethod(method.getMethod());
    il.dispose();
  }

  public static void main(String[] args) throws Exception {
    org.altervista.cp.thinbcgen.bean.test.JavaBeanInterfCreator creator = new org.altervista.cp.thinbcgen.bean.test.JavaBeanInterfCreator();
    creator.create(new FileOutputStream("org.altervista.cp.thinbcgen.bean.test.JavaBeanInterf.class"));
  }
}
